// 维修成员
import { baseUrlConfig } from '@/config/config';
import request from '@/utils/request'

const bastPath = baseUrlConfig.processBaseUrl

export interface MemberListType {
    pageNum: number,
    pageSize: number,
    condition?: {
        memberName?: string,
        companyId?: string,
        memberRole?: string,
        respOrgId?: string
    }
}

export interface ExportType {
    columns: string,
    companyId?: string,
    id: number,
    memberId: number,
    memberName: string,
    memberPhone: string,
    memberRole: string,
    respOrgId: string,
    organId: number
}

export interface MemberType {
    memberName: string,
    memberPhone?: string,
    companyId?: string,
    memberRole?: string,
    remarks?: string,
    creator: {
        id: string,
        name: string,
        organId: string,
        organName: string,
    }
}
export interface EditMemberType extends MemberType {
    memberId: string
}
export interface DeleteMemberType {
    memberId: string,
    lastMender: {
        id: string,
        name: string,
        organId: string,
        organName: string,
    }
}

// 机构数
export const repCompany = (data: any) => {
    return request({
        url: bastPath + '/rep/company/findTree',
        method: 'post',
        data
    })
}

// 获取分页列表
export const queryMemberPage = (data: MemberListType) => {
    return request({
        url: bastPath + '/rep/member/find/page',
        method: 'post',
        data
    })
}
// 新增
export const addMember = (data: MemberType) => {
    return request({
        url: bastPath + '/rep/member/append',
        method: 'post',
        data
    })
}
// 编辑
export const updateMember = (data: EditMemberType) => {
    return request({
        url: bastPath + '/rep/member/update',
        method: 'post',
        data
    })
}
// 删除
export const deleteMember = (data: DeleteMemberType) => {
    return request({
        url: bastPath + '/rep/member/delete',
        method: 'post',
        data
    })
}
// 模板下载
export const memberDownload = () => {
    return request({
        url: bastPath + '/rep/member/download',
        method: 'post',
        data: {},
        responseType: 'blob'
    })
}
// 导入列表
export const memberImport = (data: any) => {
    return request({
        url: bastPath + '/rep/member/import',
        method: 'post',
        data,
    })
}
// 导出列表
export const memberExport = (data: ExportType) => {
    return request({
        url: bastPath + '/rep/member/export',
        method: 'post',
        data,
        responseType: 'blob'
    })
}
